package com.emar.adx.yiqifa.main;

import org.apache.commons.lang.math.RandomUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by Administrator on 2015/11/18.
 */
public class ReadTest {

    public static void main(String[] args) {
        String str = "s_ln=5#srbgame=zzbq#srbip=10.154.24.253#srbgn=5304#2016-07-22 12:25:00  onlineuser:currentuser=639:currentmachine=603:maxnumonsrv=639\n" +
                "s_ln=5#srbgame=zzbq#srbip=10.154.24.253#srbgn=5304#2016-07-22 12:25:00  onlineuser:currentuser=639:currentmachine=603:maxnumonsrv=639";

        Pattern pattern = Pattern.compile("^(.+)#(\\d+-\\d+-\\d+\\s+\\d+:\\d+:\\d+).+onlineuser:(\\d+)");

        Matcher matcher = pattern.matcher(str);
        //匹配的数量
        int groupCount = matcher.groupCount();

//        String reg = "^\\d+:";
//        Pattern p = Pattern.compile(reg);
//        Matcher m = p.matcher(str);

        String[] s = pattern.split(str);

        System.out.println(s.toString());

        String[] logs = str.split("\\n");
        if(logs!=null && logs.length>0){
            for(String templog : logs){
                System.out.println(templog);
            }
        }

        for(int j = 0;j<100;j++){
            int i = RandomUtils.nextInt(10);
            System.out.println(i);
        }
    }
}
